package com.xzy.mybatis.cipher.support.strategy.crypto;

import cn.hutool.crypto.digest.MD5;
import com.xzy.mybatis.cipher.support.enums.CryptoStrategyEnum;

/**
 * 摘要加密：MD5
 *
 * @author xzy.xiao
 * @since 2025/1/17  14:52
 */
public class Md5CryptoStrategy extends CryptoStrategy {

    private final MD5 md5;

    public Md5CryptoStrategy(String salt) {
        super(salt);
        this.md5 = new MD5(salt.getBytes());
    }

    @Override
    public String getName() {
        return CryptoStrategyEnum.MD5.getCode();
    }

    @Override
    public String encrypt(String value) {
        return md5.digestHex(value);
    }

    @Override
    public String decrypt(String value) {
        return value;
    }
}
